<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//判断有没有数据提交
require("../db_conn.php");
if (isset($_POST))
{
    //收集用户输入的数据
    $yhm=$_POST['yhm'];
    $mm=$_POST['mm'];
   // $yhm=trim($_POST['yhm']);  //trim去掉字符串前后空格
   /// $mm=trim($_POST['mm']);  
    
    //比较用户输入的数据是否跟数据库中的用户信息相同
    $sql="select * from users where username='$yhm'";
    $rs=$db->query($sql);
    $row=$rs->fetch_assoc();
    if ($row)
    { 
        //有这个用户,验证密码，密码正确跳转到后台页，密码不正确，跳转login.php

        if($row['dlmm']==md5($mm))
        {
            header("Location:user.php");
        }
        else 
        {
            echo "<script>alert('Password error！');window.location.href='login.php'</script>";
        }
        
    }
    else
    {
        echo "<script>alert('User name error！');window.location.href='login.php'</script>";
        
    }
}
